Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tsconfig-paths

Package Overview
Dependencies
Maintainers
15
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tsconfig-paths

Load node modules according to tsconfig paths, in run-time or via API.

  • 3.15.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
35M
increased by3.49%
Maintainers
15
Weekly downloads
 
Created

What is tsconfig-paths?

The tsconfig-paths npm package is used to map module paths based on the paths defined in the tsconfig.json file. This allows TypeScript developers to use custom path mappings to simplify imports in their projects. It is particularly useful for avoiding relative path hell and for making the codebase cleaner and more maintainable.

What are tsconfig-paths's main functionalities?

Custom Path Mapping

This feature allows you to map paths in your TypeScript project so that you can import modules using aliases instead of relative paths. The code sample demonstrates how to register custom path mappings using the tsconfig-paths package.

require('tsconfig-paths').register({ baseUrl: './', paths: { '@app/*': ['./src/app/*'] } });

Integration with Node.js

This feature enables you to integrate tsconfig-paths with Node.js so that when you run your TypeScript-compiled JavaScript files, the custom paths are resolved correctly. The code sample shows how to run a Node.js application with tsconfig-paths support using the -r (require) flag.

node -r tsconfig-paths/register src/server.ts

Command Line Interface

tsconfig-paths provides a CLI tool called tsconfig-paths-bootstrap that can be used to bootstrap the path mappings before running your application. This is useful when you want to ensure that the path mappings are applied before any module resolution takes place.

tsconfig-paths-bootstrap

Other packages similar to tsconfig-paths

FAQs

Package last updated on 14 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc